package net.neptech.controller;

import net.neptech.model.order.OrderMaster;
import net.neptech.dto.order.OrderDTO;
import net.neptech.model.vo.OrderVo;
import net.neptech.service.OrderService;
import net.neptech.vm.ResponseResult;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.Date;

@RestController
public class OrderController {

    private  final OrderService orderService;
    public OrderController(OrderService orderService) {
        this.orderService = orderService;
    }
    @PostMapping("/create")
    public ResponseResult createOrder(@RequestBody OrderDTO orderDTO) {
        orderService.createOrder(orderDTO);
        return ResponseResult.success("创建成功");
    }

    @GetMapping("delete/{id}")
    public ResponseResult<Void> deleteOrder(@PathVariable("id") Long id) {

        return   orderService.deleteOrder(id);
    }

//    @GetMapping("getOrder/{orderId}"){
//        return  orderService.getOrderById(orderId);
//    }

    /**
     * 查找订单
     * @param orderId
     * @param typeId
     * @return
     */

    @GetMapping("getOrder/{orderId}/{typeId}")
    public ResponseResult<OrderVo> getOrder(@PathVariable("orderId") Long orderId, @PathVariable("typeId") Byte typeId) {

        return ResponseResult.success(orderService.getOrderById(orderId,typeId));
    }
    /**
     * 支付
     */

    @PostMapping("/pay")
    public ResponseResult<Void> payOrder(@RequestBody OrderDTO orderDTO) {
        return orderService.payOrder(orderDTO);
    }


}
